home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.4 Applications 1997 August / SGI IRIX 6.4 Applications 1997 August.iso / dist / mmailp.idb / usr / lib / Zmail / sgi.func.z / sgi.func
Encoding:
Text File  |  1997-01-22  |  4.2 KB  |  154 lines

  1. function forward() {
  2.     mail -f
  3. }
  4.  
  5. function gethost() {
  6.     shift 1
  7.     set __hn = "$1"
  8. }
  9.  
  10. function unset_vacation() {
  11.    sh $ZMLIB/bin/unset_vac
  12.    echo -d "Vacation program unset"
  13. }
  14.  
  15. function set_vacation() {
  16.     set __vmessage = $HOME/.vacation.msg
  17.     set __vprogram = /usr/sbin/vacation
  18.     set __reassembler = $ZMLIB/bin/reassembler
  19.     set __interval = 7
  20.     gethost $hostname
  21.         
  22.     # Validate that the vacation program exists.
  23.     if ! -e $__vprogram
  24.        error "Vacation program is not available"
  25.     endif
  26.  
  27.     # Get interval in number of days for vacation message to be resent.        
  28.     ask -i __interval "Reply interval in days:" $__interval
  29.     if $status == -1        # if user cancelled command, return now
  30.        echo "Vacation command cancelled."
  31.        return -1
  32.     endif
  33.  
  34.     # If vacation message file does not exist, create one with appropriate
  35.     # headers.
  36.     if ! -e $__vmessage
  37.        set __from = "From: $LOGNAME@$__hn ($realname)"
  38.        set __subj = "Subject: I am on vacation"
  39.        set __prec = "Precedence: bulk"
  40.        set __mess = "I am out of the office..."
  41.        sh "echo '$__from'\\n$__subj\\n$__prec\\n\\n$__mess > $__vmessage"
  42.     endif
  43.     
  44.     sh jot -f $__vmessage
  45.     sh $__vprogram -i -r $__interval
  46.     sh $ZMLIB/bin/unset_vac
  47.  
  48.     if -e $HOME/.forward
  49.         sh cp $HOME/.forward $HOME/.forward.reassembler
  50.     endif
  51.  
  52.     if $?dot_forward
  53.         sh echo '\|'$__reassembler, \"'\|'$__vprogram -a $LOGNAME@$__hn $LOGNAME\"> $HOME/.forward
  54.     else
  55.         sh echo $LOGNAME, \"'\|'$__vprogram -a $LOGNAME@$__hn $LOGNAME\"> /tmp/.forw$$
  56.         sh "sed 's/\(.*\)/\\\1/' /tmp/.forw$$ > $HOME/.forward"
  57.         remove -f /tmp/.forw$$
  58.     endif
  59.  
  60.     sh touch $HOME/.vacation_set
  61.        
  62.     echo -d "Vacation program set"
  63.     
  64. }
  65.  
  66. function vacation() {
  67.     if -e $HOME/.vacation_set
  68.        set __vac_def = "Unset"
  69.        set __vac_choices = "Set"
  70.     else
  71.        set __vac_def = "Set"
  72.        set __vac_choices = "Unset"
  73.     endif
  74.     
  75.     set __vac
  76.     ask -i __vac -m -d $__vac_def "Select Set/Unset Vacation:" $__vac_choices
  77.     if $status == -1        # if user cancelled command, return now
  78.        echo "Vacation command cancelled."
  79.        return -1
  80.     endif
  81.  
  82.     if $__vac == "Set"
  83.        set_vacation
  84.     else 
  85.        unset_vacation
  86.     endif
  87. }
  88.  
  89. if -e /usr/lib/InPerson/inpinvite
  90.     set __InPerson
  91. endif
  92.  
  93. function zmenu_reply_inperson() {
  94.     if $?[%?X-InPerson-Address?]
  95.         set __ipaddr = "$[%?X-InPerson-Address?]"
  96.     else
  97.         set __ipaddr="$[%a]"
  98.     endif
  99.     sh /usr/lib/InPerson/inpinvite -to "$__ipaddr" -subject "$[%s]"
  100. }
  101.  
  102. function print_options() {
  103.     set __print_cmd="$print_cmd"
  104.     ask -m -d "Portrait" -i __action "Select Print Options:" "Portrait" "Landscape" "Two pages/sheet" "A4" "Large"
  105.     if $status == 0
  106.         if "x$__action" == "xPortrait"
  107.             set print_cmd="$__print_cmd"
  108.         else
  109.             if "x$__action" == "xLandscape"
  110.                 set print_cmd="mailp -c30 -w4 -W170 -p $MP_PROLOGUE/mp.pro.ls.ps %O"
  111.             else
  112.                 if "x$__action" == "xTwo pages/sheet"
  113.                     set print_cmd="mailp -c25 -w4 -W80 -l %O"
  114.                 else
  115.                     if "x$__action" == "xA4"
  116.                         set print_cmd="mailp -c30 -w4 -A4 %O"
  117.                     else
  118.                         if "x$__action" == "xLarge"
  119.                             set print_cmd="mailp -c30 -w4 -W80 -p $MP_PROLOGUE/mp.pro.large.ps %O"
  120.                         endif
  121.                     endif
  122.                 endif
  123.             endif
  124.         endif
  125.         lpr
  126.         set print_cmd="$__print_cmd"
  127.     endif
  128. }
  129.  
  130. set __speakfile = $tmpdir/.mmail.speak.$$
  131. function speak() {
  132.     sh "echo 'From $[%n]. Subject $[%s].' > $__speakfile"
  133.     write $__speakfile
  134.     sh -m "Speaking message... Click Stop to end speak." -t 0 "speak < $__speakfile"
  135.     if $?child
  136.         sh -m "Stopping speak." "kill -INT $child"
  137.     endif
  138.     remove -f $__speakfile
  139.     return 0
  140. }
  141.  
  142. set __hexbin_file=''
  143. function run_hexbin() {
  144.     if "x$__hexbin_file" != "x"
  145.         ask -f __hexbin_file -d "$__hexbin_file" "Save converted file to:"
  146.     else
  147.         ask -f __hexbin_file "Save converted file to:"
  148.     endif
  149.     if $status == 0
  150.         sh hexbin -d -s "$1" > "$__hexbin_file"
  151.     endif
  152.     return 0
  153. }
  154.